package net.towee.client.event.core;

import java.util.Arrays;
import java.util.List;

import net.towee.model.repo.NodeData;

import com.google.gwt.event.shared.GwtEvent;

public class NodeReceivedEvent extends GwtEvent<NodeReceivedHandler> {
	public static Type<NodeReceivedHandler> TYPE = new Type<NodeReceivedHandler>();
	private final List<NodeData> nodes;

	public NodeReceivedEvent(List<NodeData> result) {
		this.nodes = result;
	}

	public NodeReceivedEvent(NodeData result) {
		this.nodes = Arrays.asList( result );
	}

	@Override
	public Type<NodeReceivedHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(NodeReceivedHandler handler) {
		handler.onNodesReceived( nodes );
	}

}
